Special Character Must Be Replaced

From Documentation
Special Character Must Be Replaced


Stop.png This documentation is for an older version of ZK. For the latest one, please click here.


XML use <element-name> to denote an element, so you have to replace special characters. For example, you have to use &lt; to represent the < character.


Special Character
Replaced With
<
&lt;
>
&gt;
&
&amp;
"
&quot;
'
&apos;
\t (TAB)
&#x09;
Required only if use it in a XML attribute's value
\n (Linefeed)
&#x0a;
Required only if use it in a XML attribute's value

Alternatively, you could tell XML parser not to interpret a piece of text by using CDATA as the following.

 <zscript>
 <![CDATA[
 void myfunc(int a, int b) {
     if (a < 0 && b > 0) {
         //do something
     }
 ]]>
 </zscript>

It is suggested to always add <![CDATA[ ]]> inside your <zscript> </zscript>. Thus you don't have to worry about escape sequences for special characters like "&", "<". In addition, the code is much easier to read and maintain.



Last Update : 2022/01/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.